/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeEList;

import org.xtext.example.cr.cR.Archive;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Folder;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Archive</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArchiveImpl#getFolder <em>Folder</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArchiveImpl#getArq <em>Arq</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArchiveImpl extends MinimalEObjectImpl.Container implements Archive
{
  /**
   * The cached value of the '{@link #getFolder() <em>Folder</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFolder()
   * @generated
   * @ordered
   */
  protected Folder folder;

  /**
   * The cached value of the '{@link #getArq() <em>Arq</em>}' attribute list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArq()
   * @generated
   * @ordered
   */
  protected EList<String> arq;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ArchiveImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.ARCHIVE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Folder getFolder()
  {
    return folder;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFolder(Folder newFolder, NotificationChain msgs)
  {
    Folder oldFolder = folder;
    folder = newFolder;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.ARCHIVE__FOLDER, oldFolder, newFolder);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFolder(Folder newFolder)
  {
    if (newFolder != folder)
    {
      NotificationChain msgs = null;
      if (folder != null)
        msgs = ((InternalEObject)folder).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.ARCHIVE__FOLDER, null, msgs);
      if (newFolder != null)
        msgs = ((InternalEObject)newFolder).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.ARCHIVE__FOLDER, null, msgs);
      msgs = basicSetFolder(newFolder, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ARCHIVE__FOLDER, newFolder, newFolder));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<String> getArq()
  {
    if (arq == null)
    {
      arq = new EDataTypeEList<String>(String.class, this, CRPackage.ARCHIVE__ARQ);
    }
    return arq;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.ARCHIVE__FOLDER:
        return basicSetFolder(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.ARCHIVE__FOLDER:
        return getFolder();
      case CRPackage.ARCHIVE__ARQ:
        return getArq();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.ARCHIVE__FOLDER:
        setFolder((Folder)newValue);
        return;
      case CRPackage.ARCHIVE__ARQ:
        getArq().clear();
        getArq().addAll((Collection<? extends String>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ARCHIVE__FOLDER:
        setFolder((Folder)null);
        return;
      case CRPackage.ARCHIVE__ARQ:
        getArq().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ARCHIVE__FOLDER:
        return folder != null;
      case CRPackage.ARCHIVE__ARQ:
        return arq != null && !arq.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (arq: ");
    result.append(arq);
    result.append(')');
    return result.toString();
  }

} //ArchiveImpl
